%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Assemble the matrix that maps an charge distribution to a
% potential on C
% 
% kh       Helmholtz parameter.
% C        contour
% ind      indices of the points to consider on C
% zz       position of the charges
% h        point spacing on the outer contour (assumed to be uniform)
% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function res = get_C(kh,C,ind,zz,h)

M = size(zz,2);
n = size(ind ,2);

% dist1(i,j) = x1(i) - z1(j)
dist1 = (C(1,ind)' * ones(1,M)) - ones(n,1)*zz(1,:);
% dist2(i,j) = x2(i) - z2(j)
dist2 = (C(4,ind)' * ones(1,M)) - ones(n,1)*zz(2,:);

dd   = sqrt(dist1.^2 + dist2.^2);

res = funcPhi(kh,dd)*h;

return
